<%@ page language="java" contentType="text/html;UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="com.bear.model.entity.forum.actionForm.*" %>
<%@ page import="com.bear.model.entity.User" %>
<%@ page import="com.bear.model.entity.userInfo.*" %>
<%@include file="../base.jsp" %>

<title>我的消息</title>
<%List<FullMessage> messages = (List<FullMessage>)request.getAttribute("messages"); %>
<script>
function handleHi(messageid,agree,fromid)
{
	$("#mi2").val(messageid);
	$("#ag2").val(agree);
	$("#fromu2").val(fromid);
	$("#sayhi").submit();
}
function handleFriend(messageid,agree,fromid)
{
	$("#mi").val(messageid);
	$("#ag").val(agree);
	$("#fromu").val(fromid);
	$("#handlefriend").submit();
}
</script>
</head>
<body>

<img src="<c:url value="/ico/egg.jpg"/>" height="50"><font class="thick">我的消息</font><br>
<div class="demo-info">
	<div class="demo-tip icon-tip"></div>
	<div>看看谁给我发消息了</div>
</div>
<a href="<c:url value="/App.html"/>" class="easyui-linkbutton" >首页</a>
<a href="<c:url value="/userInfo.html"/>" class="easyui-linkbutton" >看看都有谁</a>
<%for(FullMessage m:messages){
	int mstype = m.getMessagetype();
	if(1==mstype){
%>
<table>
	<tr>
	<td rowspan="3"><img 
src="<c:url value="<%=m.getFromuser().getPhotoAddress() %>"/>" 
height="50"></td>
	<td>内容：</td><td><%=m.getContent() %></td>
	<td><a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="handleFriend(<%=m.getId()%>,'yes',<%=m.getFromuser().getId() %>)">同意</a></td>
	<td><a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-no'" onclick="handleFriend(<%=m.getId()%>,'no',<%=m.getFromuser().getId() %>)">拒绝</a></td>
	</tr>
	<tr>
	<td rowspan="2">时间:</td><td><%=m.getTime()%></td>
	</tr>
</table>
<% 
}
	else
	{
%>
<table>
	<tr>
	<td rowspan="3"><img 
src="<c:url value="<%=m.getFromuser().getPhotoAddress() %>"/>" 
height="50"></td>
	<td>内容：</td><td><%=m.getContent() %></td>
	<td><a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-undo'" onclick="handleHi(<%=m.getId()%>,'yes',<%=m.getFromuser().getId() %>)">打个招呼回去</a></td>
	<td><a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-no'" onclick="handleHi(<%=m.getId()%>,'no',<%=m.getFromuser().getId() %>)">知道了</a></td>
	</tr>
	<tr>
	<td rowspan="2">时间:</td><td><%=m.getTime()%></td>
	</tr>
</table>
<% 		
	}
}
%>
<form id="handlefriend" action="<c:url value="/userInfo/handlemessage.html"/>" method="post">
<input id="mi" type="hidden" name="messageid" >
<input id="ag" type="hidden" name="agree">
<input id="fromu" type="hidden" name="fromu">
</form>
<form id="sayhi" action="<c:url value="/userInfo/sayhimessage.html"/>" method="post">
<input id="mi2" type="hidden" name="messageid" >
<input id="ag2" type="hidden" name="agree">
<input id="fromu2" type="hidden" name="fromu">
</form>
<%@include file="../botton.jsp" %>
</body>
</html>